# Maintainer: George Rawlinson <grawlinson@archlinux.org>
# Contributor: Jokler <aur@jokler.xyz>

pkgname=bacon
pkgver=2.12.1
pkgrel=1
pkgdesc='A background rust code checker'
arch=('loong64' 'x86_64')
url='https://dystroy.org/bacon'
license=('AGPL3')
depends=('glibc' 'gcc-libs')
makedepends=('git' 'rust')
options=('!lto')
_commit='6fb5ab6b5fd61f5fecab149a290b07bfe999b432'
source=("$pkgname::git+https://github.com/Canop/bacon#commit=$_commit")
b2sums=('SKIP')

pkgver() {
  cd "$pkgname"

  git describe --tags | sed 's/^v//'
}

prepare() {
  cd "$pkgname"

  cargo fetch --locked --target "$CARCH-unknown-linux-gnu"
}

build() {
  cd "$pkgname"

  cargo build --frozen --release --all-features
}

check() {
  cd "$pkgname"

  cargo test --frozen --all-features
}

package() {
  cd "$pkgname"

  # binary
  install -vDm755 -t "$pkgdir/usr/bin" "target/release/$pkgname"

  # documentation
  install -vDm644 -t "$pkgdir/usr/share/doc/$pkgname" ./*.md
  cp -vr doc img "$pkgdir/usr/share/doc/$pkgname"

  # license
  install -vDm644 -t "$pkgdir/usr/share/licenses/$pkgname" LICENSE
}
